package com.example.provider.controller;

import com.example.common.entity.Company;
import com.example.common.entity.Message;
import com.example.common.entity.WorkRoom;
import com.example.provider.service.AdminService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 用于后台管理系统的各个功能
 */
@RestController
@RequestMapping("/admin")
public class AdminController {
    @Autowired
    private AdminService adminService;

    /**
     * 从数据库取出处于审批中的企业注册信息
     * @return
     */
    @GetMapping("/getCompany")
    public List<Company> getCompany(){
        return adminService.getCompany();
    }

    /**
     * 通过企业注册申请
     * @param company
     * @return
     */
    @PostMapping("/pass")
    public Message pass(@RequestBody Company company){
        return adminService.pass(company);
    }

    /**
     * 驳回企业注册申请
     * @param company
     * @return
     */
    @PostMapping("/reject")
    public Message reject(@RequestBody Company company){
        return adminService.reject(company);
    }

    /**
     * 从数据库取出处于审批中的工作室注册信息
     * @return
     */
    @GetMapping("/getWorkroom")
    public List<WorkRoom> getWorkroom(){
        return adminService.getWorkroom();
    }

    /**
     * 通过工作室注册申请
     * @return
     */
    @PostMapping("/passWorkroom")
    public Message passWorkroom(@RequestBody WorkRoom workRoom){
        return adminService.passWorkroom(workRoom);
    }

    /**
     * 驳回工作室注册申请
     * @param workRoom
     * @return
     */
    @PostMapping("/rejectWorkroom")
    public Message rejectWorkroom(@RequestBody WorkRoom workRoom){
        return adminService.rejectWorkroom(workRoom);
    }
}
